home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / logicsim.arc / LOGICSIM.PAS < prev   
Pascal/Delphi Source File  |  1986-01-08  |  5KB  |  117 lines

  1.  
  2. {------------------------------------------------------------------------}
  3. {                     Logic Simulation program                           }
  4. {                     Original Basic version by                          }
  5. {                        Robert M. McDermott;                            }
  6. {         Pascal program by: Greg C. Miner         April 1985            }
  7. {------------------------------------------------------------------------}
  8.  
  9.  
  10. PROGRAM Logic_Simulator;
  11.  
  12. Const
  13.      SCREEN      = 22;      LINE        =  80;
  14.      MNAMS       = 600;     MLGIC       = 600;
  15.      MTYPES      = 200;     MEXTERN     = 100;
  16.      MSAMPLES    = SCREEN;  L0          =   0;
  17.      L1          =   3;     LX          =   1;
  18.  
  19. Var
  20.    Filvar,Device:                     Text;
  21.    Filename:                          String[10]; {source file input var}
  22.    Ok:                                Boolean;
  23.    Ls,ASK,Xs,XXs,Header:              String[80];
  24.    NAMES:  Array[0..MNAMS]         of String[8];  {Signal Names          }
  25.    TEX:    Array[0..1]             of String[1];  {                      }
  26.    TYPES:  Array[0..MTYPES]        of String[8];  {Logic Types           }
  27.    TYPEX:  Array[0..MTYPES]        of Integer;    {Pointers to logic desc}
  28.    LIs:    Array[0..10]            of String[8];  {Temporary             }
  29.    LOGIN:  Array[0..3]             of String[8];  {Logic Input Symbol    }
  30.    LOGPR:  Array[0..3]             of String[8];  {Logic Print Symbol    }
  31.    LNOT:   Array[0..3]             of Integer;    {Logic Inversion       }
  32.    LV:     Array[0..3]             of Integer;    {                      }
  33.    LO:     Array[0..MLGIC,0..8]    of Integer;    {Logic Description     }
  34.    EX:     Array[0..MEXTERN,0..10] of Integer;    {External Stimuli      }
  35.    OLD:    Array[0..MNAMS]         of Integer;    {Old logic value array }
  36.    SAMPLED:Array[0..MSAMPLES]      of Integer;    {Sampled Nodes         }
  37.    T:      Array[0..10]            of Integer;    {Temporary             }
  38.    INPUT:  Array[0..10]            of Integer;
  39.  
  40.    XC,XD,XM,D0,D1,YE,DL,
  41.    Q0,Q1,Y0,Y1,YC,YL,XSS,XR,XL,
  42.    XQ,C9,XO,PX,PY,PC,L,LT,
  43.    MX,NLGIC,NTYPE,NPRIM,I,I1,I2,II,J,LI,
  44.    FOUND,TPTR,SLGIC,NNAM,ERROR,MM,LOx,T1,TIME,
  45.    INCREMENT,X,X1,TL,STF,Y,M1,K,K1,FM,
  46.    XX,NE,NSAMPLED,E0,E1,E2,E3,E9,RI:       Integer;
  47.  
  48.    NEW:    Array[0..MLGIC]         of Integer;
  49.    ME:     Array[0..MLGIC,0..1]    of Integer;
  50.    S0:     Array[0..400]           of Integer;
  51.    S1:     Array[0..400]           of Integer;
  52.    S2:     Array[0..400]           of Integer;
  53.  
  54. {$ILogicsim.inc}
  55.  
  56. Begin (*............. MAIN .............*)
  57. ClrScr;
  58. Writeln('{----------------------------------------------------------------}');
  59. Writeln('{                    Logic Simulation program                    }');
  60. Writeln('{                    Original Basic version by                   }');
  61. Writeln('{                       Robert M. McDermott;                     }');
  62. Writeln('{      Pascal program by: Greg C. Miner         April 1985       }');
  63. Writeln('{                                                                }');
  64. Writeln('{        For information and operational description see         }');
  65. Writeln('{          "The Design of an Advanced Logic Simulator"           }');
  66. Writeln('{                    BYTE Magazine, April 1983                   }');
  67. Writeln('{----------------------------------------------------------------}');
  68. Writeln;
  69.  
  70. Writeln('          ',MNAMS,' Names, ',MLGIC,' Logic Devices,');
  71. Writeln('          ',MTYPES,' Types,  ',MEXTERN,' External Stimuli');
  72. Repeat
  73.  Writeln; Writeln;
  74.  Write(' Source file name: ');
  75.  Read(Filename); writeln; writeln;
  76.  I:=pos(filename,':');
  77.  if I=0 then Filename:=Filename+'.LGC';
  78.  Assign(Filvar,Filename);
  79.  {$I-} reset(Filvar); {$I+}
  80.  Ok:=(IOresult=0);
  81.  if not Ok then Writeln('File: ',Filename,'.LGC not found.');
  82. until Ok;
  83. Writeln;
  84.  
  85. Write('Output Expansion to ''P''rinter, ''F''ile ? ');
  86. Readln(ASK); Ask:=Ask+' ';
  87. Ask:=upcase(copy(Ask,1,1));
  88. Assign(Device,'CON:');
  89. if Ask='P' then Assign(Device,'LST:');
  90. if Ask='F' then Assign(Device,copy(filename,1,length(filename)-3)+'LST');
  91. ClrScr;
  92. Rewrite(Device);
  93. Writeln(Device,'Logic Simulator: ',Filename);
  94. Writeln(Device);
  95.  
  96. Writeln('*****        Initializing Arrays');
  97. Initialize;
  98. Writeln('*****       Reading in any Macros');
  99. ReadMacros;
  100. Writeln('*****       Reading in Logic Network');
  101. Header:='Logic Network';
  102. WriteHeader;
  103. ReadInLogicDescription;
  104. Writeln('*****       Expanding any Macros');
  105. ExpandMacros;
  106. ListExpansion;
  107. Writeln('*****       Reading in External Stimuli');
  108. ReadExternals;
  109. Writeln('*****       Checking for Errors');
  110. CheckErrors;
  111. Writeln('*****       Reading in Nodes to be Sampled');
  112. ReadNodes;
  113. Writeln('*****       Setting up for Simulation');
  114. SetUpSimulation;
  115. Close(Device);
  116. END.
  117.